﻿using System;
using System.Collections.Generic;
using System.Management.Automation;

using CrystalDecisions.Enterprise.Desktop;

namespace BO.Management.PowerShell
{
    [Cmdlet(VerbsCommon.Get, "JobServerMetrics", DefaultParameterSetName = CONNECT_SECWINAD)]
    public class GetJobServerMetrics : BaseActionObject<ServerProvider, Server>
    {

        public override ServerProvider GetProvider()
        {
            return new ServerProvider(this.LogonProvider);
        }

        public override void WorkWithListObjects(List<Server> boeObjects)
        {
            foreach (Server server in boeObjects)
            {
                this.WorkWithSingleObject(server);
            }
        }

        public override void WorkWithSingleObject(Server boeObject)
        {
            switch (this.InputObject.ServerKind)
            {
                case "jobserver":
                    this.WriteObject(new CrystalDecisions.Enterprise.Admin.JobServerAdmin(this.InputObject.ServerAdmin));
                    break;
                case "aps":
                    this.WriteObject(new CrystalDecisions.Enterprise.Admin.ApsAdmin(this.InputObject.ServerAdmin));
                    break;
                case "rptappserver":
                    this.WriteObject(new CrystalDecisions.Enterprise.Admin.ReportAppServerAdmin(this.InputObject.ServerAdmin));
                    break;
                case "fileserver":
                    this.WriteObject(new CrystalDecisions.Enterprise.Admin.FileServerAdmin(this.InputObject.ServerAdmin));
                    break;
                case "eventserver":
                    this.WriteObject(new CrystalDecisions.Enterprise.Admin.EventServerAdmin(this.InputObject.ServerAdmin));
                    break;
                case "pageserver":
                    this.WriteObject(new CrystalDecisions.Enterprise.Admin.PageServerAdmin(this.InputObject.ServerAdmin));
                    break;
                case "cacheserver":
                    this.WriteObject(new CrystalDecisions.Enterprise.Admin.CacheServerAdmin(this.InputObject.ServerAdmin));
                    break;
                default:
                    this.WriteObject(this.InputObject.ServerGeneralAdmin);
                    Console.WriteLine("This server kind {0} is not managed");
                    break;
            }

        }

    }
}
